import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:industry_net/base/common/upload.dart';
import 'package:industry_net/base/common/util.dart';
import 'package:industry_net/base/component/component.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class ChatPage extends GetView<ChatController> {
  const ChatPage({Key? key}) : super(key: key);

  // 内容页
  Widget _buildView() {
    return GestureDetector(
      onTap: () {
        controller.state.isAdding = false;
        controller.state.focusNode.unfocus();
        controller.update();
      },
      child: ListView.builder(
          reverse: true,
          itemBuilder: (context, index) {
            if (index == 0) {
              return ChatBar();
            }
            var md = controller.state.list[index - 1];
            return md.itemCell;
          },
          itemCount: controller.state.list.length + 1),
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ChatController>(
      builder: (_) {
        return Scaffold(
          appBar: detailAppBar(context),
          body: _buildView(),
        );
      },
    );
  }
}
